/* ========================================================================== */
/*   OperationController.cpp    		                                      */
/*   (c) 2012 Team 7 Hogeschool Utrecht ICT TI                                */
/*		Lars Stolwijk, Gerben Boot, Guido van Hienen, Marcel Boelen			  */
/*                                                                            */
/*   Starts and stops the entire game. At start gives Log command to clear 	  */
/*		the log														          */
/* ========================================================================== */
#include "OperationController.h"

void OperationController::main()
{
	CurrentState = STANDBY;
	for(;;)
	{
		if(CurrentState == STANDBY)
		{
			//std::cout << "OC->STANDBY\n";
			RTOS::event e = wait( PlayEndGameFlag );
			CurrentState = RUNNING;
		}
		else if(CurrentState == RUNNING)
		{
			//std::cout << "OC->RUNNING\n";
			std::cout << "OperationController start\n";
			theLog->ClearLog();
			theSoundController->PlayActivateDeactivatePlayerSound();
			theGameHandler->StartGame();

			RTOS::event e = wait( PlayEndGameFlag  );

			std::cout << "OperationController stop\n";
			theSoundController->PlayActivateDeactivatePlayerSound();
			theGameHandler->StopGame();

			CurrentState = STANDBY;
		}
	}
}

void OperationController::PlayEndGame()
{
	PlayEndGameFlag.set();
}
